/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ControlLager;
import ModelLager.*;
import DBLager.*;
import java.sql.SQLException;
import java.util.ArrayList;
/**
 *
 * @author Jonas Kristensen
 */
public class SupplierPCTR 
{
    private IFDBSup dbSup;
    
    public SupplierPCTR()
    {
        dbSup = new DbSupplierP();
    }
    
    public SupplierP findSupplierByID(int id)
    {
        return dbSup.findSupplier(id);
    }
    
    public ArrayList<SupplierP> findSuppliersByName(String name)
    {
        return dbSup.getSuppliersByName(name);
    }
    
    public ArrayList<SupplierP> getAllSuppliers()
    {
        return dbSup.getAllSuppliers();
    }
    
//    public int createSupplier(SupplierP supObj)
//    {
//        IFDBSup dbSup = new DbSupplierP();
//        
//        SupplierP subObj = new SupplierP(name, address, country, phoneNo, email, supplierID, zipCode);
        
        public int createSupplier(String name, String address, String country, String phoneNo, String email, int supplierID, String zipCode, String city) throws SQLException, Exception
    {
        SupplierP supObj = new SupplierP(name, address, country, phoneNo, email, supplierID, zipCode);
        return dbSup.insertSupplier(supObj);
    }
    
    public int updateSupplier(String name, String address, String country, String phoneNo, String email, int supplierID, String zipCode) throws SQLException, Exception
    {
        SupplierP supObj = new SupplierP();
        supObj.setName(name);
        supObj.setAddress(address);
        supObj.setCountry(country);
        supObj.setPhoneNo(phoneNo);
        supObj.setEmail(email);
        supObj.setSupplierID(supplierID);
        supObj.setZipCode(zipCode);
        
        return dbSup.updateSupplier(supObj);
    }
    
    public int deleteSupplier(int supplierID)
    {       
        return dbSup.deleteSupplier(supplierID);
    }
    
    
}
